Body Event
Description:
This is just a demonstration record showing some signal slot events that are used when the receivingContact property of a Body is set to true. And they are meant to be used for collision detection between Body objects.
Usage:
-- you can register for these events using codes
body.receivingContact = true
body:slot("BodyEnter", function(other: Body, sensorTag: integer)
print("A body enter senser", other, sensorTag)
end)
BodyEnter
Type: Node Event.
Description:
Triggers when a Body object collides with a sensor object.
Signature:
["BodyEnter"]: function(other: Body, sensorTag: integer)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is colliding with. |
sensorTag | integer | The tag of the sensor that triggered this collision. |
BodyLeave
Type: Node Event.
Description:
Triggers when a Body
object is no longer colliding with a sensor object.
Signature:
["BodyLeave"]: function(other: Body, sensorTag: integer)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is no longer colliding with. |
sensorTag | integer | The tag of the sensor that triggered this collision. |
ContactStart
Type: Node Event.
Description:
Triggers when a Body
object starts to collide with another object.
Signature:
["ContactStart"]: function(other: Body, point: Vec2, normal: Vec2)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is colliding with. |
point | Vec2 | The point of collision in world coordinates. |
normal | Vec2 | The normal vector of the contact surface in world coordinates. |
ContactEnd
Type: Node Event.
Description:
Triggers when a Body
object stops colliding with another object.
Signature:
["ContactEnd"]: function(other: Body, point: Vec2, normal: Vec2)
Parameters:
Parameter | Type | Description |
---|---|---|
other | Body | The other Body object that the current Body is no longer colliding with. |
point | Vec2 | The point of collision in world coordinates. |
normal | Vec2 | The normal vector of the contact surface in world coordinates. |